package com.mz.ozy.widget;

import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.util.AttributeSet;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;

import com.qmuiteam.qmui.util.QMUIStatusBarHelper;

public class StatusBar extends View {
    public StatusBar(Context context) {
        super(context);
    }

    public StatusBar(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public StatusBar(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    public StatusBar(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    @Override
    //只有4.4以上的版本，状态栏才可操作
    @TargetApi(Build.VERSION_CODES.KITKAT)
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);

        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
            setMeasuredDimension(getWidth(), QMUIStatusBarHelper.getStatusbarHeight(getContext()));
        } else {
            setMeasuredDimension(getWidth(), 0);
        }
    }


}
